package com.ruoyi.rotation.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.rotation.mapper.RotationMapper;
import com.ruoyi.rotation.domain.Rotation;
import com.ruoyi.rotation.service.IRotationService;

/**
 * 轮播图Service业务层处理
 *
 * @author duanxinli
 * @date 2023-11-22
 */
@Service
public class RotationServiceImpl implements IRotationService {
    @Autowired
    private RotationMapper rotationMapper;

    /**
     * 查询轮播图
     *
     * @param id 轮播图主键
     * @return 轮播图
     */
    @Override
    public Rotation selectRotationById(String id) {
        return rotationMapper.selectRotationById(id);
    }

    /**
     * 查询轮播图列表
     *
     * @param rotation 轮播图
     * @return 轮播图
     */
    @Override
    public List<Rotation> selectRotationList(Rotation rotation) {
        return rotationMapper.selectRotationList(rotation);
    }

    /**
     * 新增轮播图
     *
     * @param rotation 轮播图
     * @return 结果
     */
    @Override
    public int insertRotation(Rotation rotation) {
        rotation.setId(IdUtils.fastUUID());
        rotation.setCreateDate(DateUtils.getNowDate());
        String username = SecurityUtils.getUsername();
        rotation.setCreateBy(username);
        rotation.setDelFlag(0L);
        return rotationMapper.insertRotation(rotation);
    }

    /**
     * 修改轮播图
     *
     * @param rotation 轮播图
     * @return 结果
     */
    @Override
    public int updateRotation(Rotation rotation) {
        return rotationMapper.updateRotation(rotation);
    }

    /**
     * 批量删除轮播图
     *
     * @param ids 需要删除的轮播图主键
     * @return 结果
     */
    @Override
    public int deleteRotationByIds(String[] ids) {
        return rotationMapper.deleteRotationByIds(ids);
    }

    /**
     * 删除轮播图信息
     *
     * @param id 轮播图主键
     * @return 结果
     */
    @Override
    public int deleteRotationById(String id) {
        return rotationMapper.deleteRotationById(id);
    }
}
